import { Controller, Get, Post, Body, Patch, Param, Delete,Req } from '@nestjs/common';
import { ApiTags,ApiOperation, ApiResponse } from '@nestjs/swagger';
import { Request } from 'express'
import {UserService} from '../system/user/user.service'
import { User } from 'src/system/user/entities/user.entity';
import {MenuService} from 'src/system/menu/menu.service'

@ApiTags('账户管理')
@Controller('account')
export class AccountController {
  constructor(
    private readonly userService: UserService,
    private menuService: MenuService
  ) {}

  @Get('info')
  @ApiOperation({ summary: '获取用户信息' })
  getUserInfo(@Req() req:Request) {
    let exitUser = req.user as User;
    // 获取用户信息逻辑
    return this.userService.findOne(exitUser.id);
  }

  @Get('permmenu')
  @ApiOperation({ summary: '获取菜单列表及权限列表' })
  async getPermMenu(@Req() req:Request) {
    let exitUser = req.user as User;
    const menus = await this.menuService.getMenus(exitUser.id);
    const perms = await this.menuService.getPerms(exitUser.id);
    return { menus, perms };
  }
}
